aboutsummaryrefslogtreecommitdiffstats
path: root/src/app/groups/[groupId]/layout.tsx
diff options
context:
space:
mode:
authorSebastien Castiel <sebastien@castiel.me>2023-12-06 12:22:24 -0500
committerSebastien Castiel <sebastien@castiel.me>2023-12-06 12:22:24 -0500
commit6c4ced0f79f801d85da5e4973ae4154f01b04dba (patch)
treedbb8eab58ef6d3e8cec6f3c7187e2a4596134d4a /src/app/groups/[groupId]/layout.tsx
parented55c696cd083bfaa5429082a9c5edd4ebde0cd8 (diff)
Loading screens & layouts
Diffstat (limited to 'src/app/groups/[groupId]/layout.tsx')
-rw-r--r--src/app/groups/[groupId]/layout.tsx37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/app/groups/[groupId]/layout.tsx b/src/app/groups/[groupId]/layout.tsx
new file mode 100644
index 0000000..f8030c6
--- /dev/null
+++ b/src/app/groups/[groupId]/layout.tsx
@@ -0,0 +1,37 @@
+import { Button } from '@/components/ui/button'
+import { getGroup } from '@/lib/api'
+import { ChevronLeft, Edit } from 'lucide-react'
+import Link from 'next/link'
+import { notFound } from 'next/navigation'
+import { PropsWithChildren } from 'react'
+
+export default async function GroupLayout({
+ children,
+ params: { groupId },
+}: PropsWithChildren<{
+ params: { groupId: string }
+}>) {
+ const group = await getGroup(groupId)
+ if (!group) notFound()
+
+ return (
+ <main>
+ <div className="mb-4 flex justify-between">
+ <Button variant="ghost" asChild>
+ <Link href="/groups">
+ <ChevronLeft className="w-4 h-4 mr-2" /> Back to recent groups
+ </Link>
+ </Button>
+ <Button variant="secondary" asChild>
+ <Link href={`/groups/${groupId}/edit`}>
+ <Edit className="w-4 h-4 mr-2" /> Edit group settings
+ </Link>
+ </Button>
+ </div>
+
+ <h1 className="font-bold mb-4">{group.name}</h1>
+
+ {children}
+ </main>
+ )
+}